package engine.newUi
{
	import engine.control.TurnPapersViewGroup;
	import engine.data.BindManage;
	import engine.data.ModelLocator;
	import engine.data.Record;
	import engine.data.ResPath;
	import engine.flag.ResourcesPath;
	import engine.logic.LogSendLogic;
	import engine.logic.SceneTransfer;
	import engine.net.event.CustomMsgEvent;
	import engine.net.messages.CustomToClientFlag;
	import engine.net.messages.CustomToServerFlag;
	import engine.net.mgr.SystemSender;
	import engine.tip.TipsMainLogic;
	import engine.ui.AlertUI;
	import engine.ui.MainLogic;
	
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.net.URLLoader;
	import flash.text.TextField;
	import flash.utils.setTimeout;
	
	import mx.resources.ResourceManager;
	
	import newx.StageInfo;
	import newx.com.ResManager;
	import newx.com.config.StaticIni;
	import newx.com.control.NxClip;
	import newx.com.control.button.NxButton;
	import newx.com.control.window.NxWindowEvent;
	import newx.com.loader.SwfLoader;
	import newx.utils.FilterUtil;

	/**
	 * 精英副本逻辑类 
	 * @author wanghb
	 * 
	 */
	public class EliteFBListLogic
	{
		private var _myDis			:EliteFBUI;
		private static var _self	:EliteFBListLogic;
		private var _starInt		:int 	= 2;
		private var _endInt		:int	= 8;
		private var _oldItem		:MovieClip	=	null;
		//副本ID号
		private var _FBSceneID:String		=	"0";
		//副本类型
		private var _FBSceneType:String	=	"";
		//精英副本项数组
		private var _fbListArray	:Array;
		//当前可进的副本索引号
		private var _isCanInitFbIndex:int	=	0;
		private var _WindowIsOk:Boolean	=	false;
		private var _levle:int	
		private var _resNum:int;
		private var _model:ModelLocator;
		private var _fristFBSceneObj:Object;
		private var _turnPagersViewGroup:TurnPapersViewGroup;
		private var _FBTaskLogic:FBTaskLogic;
		
		private var _isanew:Boolean = false;
		
		private var _blindFlag:int = -1;
		private const ELITEFBLIST_TYPE:int		=	7;
		private var _eliteFBCount:int = -1;
		
		
		private const VIPCONFIGID:int =39021011; 
		public function EliteFBListLogic()
		{
			init();
		}
		public static function getInstance():EliteFBListLogic
		{
			if(_self == null)
			{
				_self	=	new EliteFBListLogic();
			}
			return _self;
		}
		/**
		 * 指定打开的副本号和提示类型; 
		 * @param id
		 * @param type
		 * 
		 */		
		public function intoFBSceneID(id:String,type:String):void
		{
			_FBSceneID		=	id;
			_FBSceneType	=	type;
		}
		/**
		 * 添加事件 
		 */		
		public function addListener():void
		{
			//精英副本底图
//			ResourcesPath
//			SwfLoader.StartLoad(StageInfo.swfResPath+"EliteBack.swf", null, onSceneBGLoadComplete );
			ResManager.loadRes( "EliteBack", ResPath.SWF + "EliteBack.swf", onComplete );
			
			var _record:Record = _model.scene.GetRecordEx("VIPCountRec");
			var _arr:Array = _record.recArr;
			for(var i:String in _arr){
				if(_arr[i][0] == ELITEFBLIST_TYPE){
					var useCount:int = _arr[i][1];
					var allCount:int = _arr[i][2];
					var cardCount:int = _arr[i][3];
					_eliteFBCount = allCount + cardCount - useCount;
				}
			}
			
			BindManage.getInstance().BindProp(_model.scene.Role,"VIPLevel",this,"level");
			BindManage.getInstance().BindProp(_model.scene.Role,"FBResetStatus",this,"resetNum");
			
			function onComplete(swf:DisplayObject,pList:Array = null):void
			{
				var mc : MovieClip = ResManager.newResClass( "EliteBack") as MovieClip;
				_myDis.backMc.source = mc;
			}
			_turnPagersViewGroup	.addListener();
			_myDis.windowBG			.addEventListener(NxWindowEvent.WINDOW_CLOSE,			closeHandle);
			_myDis.anewBtn			.addEventListener(MouseEvent.CLICK,						clickHandle);
			_myDis.wipeout			.addEventListener(MouseEvent.CLICK,						clickHandle);
			_WindowIsOk				=	true;
			_myDis.windowBG.nxWindowhelpBtn			.addEventListener(MouseEvent.MOUSE_OVER,OverhelpHandler);
			_myDis.windowBG.nxWindowhelpBtn			.addEventListener(MouseEvent.MOUSE_OUT,OuthelpHandler);
			showInfo();
		}
		/**
		 * 
		 * 
		 */
//		private function onSceneBGLoadComplete(val:MovieClip,pList:Array):void
//		{
//			_myDis.addChildAt(val,0)
//		}
		/**
		 * 移除事件 
		 */		
		public function removeListener():void
		{
			_turnPagersViewGroup	.removeListener();
			_myDis.windowBG			.removeEventListener(NxWindowEvent.WINDOW_CLOSE,		closeHandle);
			_myDis.anewBtn			.removeEventListener(MouseEvent.CLICK,					clickHandle);
			_myDis.wipeout			.removeEventListener(MouseEvent.CLICK,					clickHandle);
			_FBSceneID	=	"";
			if(_blindFlag!=-1)
			{
				_blindFlag= BindManage.getInstance().UnbindRecord("FakeVipRec", _blindFlag);
			}
		}
		/**
		 * VIPLEVEL等级 
		 * @param val
		 * 
		 */		
		public function set level(val:int):void
		{
			_levle	=	val;
			isCanRes();
		}
		/**
		 * 重置次数 
		 * @param val
		 * 
		 */		
		public function set resetNum(val:int):void
		{
			_resNum	=	val
			isCanRes();
		}
		/**
		 * 是否需要打开 
		 * @return 
		 * 
		 */		
		public function get WindowIsOk():Boolean
		{
			return _WindowIsOk
		}
		/**
		 * 是否需要打开 
		 * @return 
		 * 
		 */		
		public function set WindowIsOk(val:Boolean):void
		{
			_WindowIsOk	=	val;
		}
		/**
		 * 返回当前章节名 
		 * @return 
		 * 
		 */		
		public function get pageName():String
		{
			var listObj	:Object		=	StaticIni.getIniObj("JY_"+ String(1 + _turnPagersViewGroup.nowPage));
			return(listObj["actName"]);
		}
		private function init():void
		{
			_model						=	ModelLocator.getInstance()
			_FBTaskLogic				=	FBTaskLogic.getInstance();
			_myDis						=	EliteFBUI.getInstance();
			_myDis.intoEffect.visible	=	false;
			_myDis.intoEffect.gotoAndStop(1);
			initItemPic();
			_turnPagersViewGroup		=	new TurnPapersViewGroup(_myDis.fb_frame,_myDis.leftBtn,_myDis.rightBtn,showItem,removeItem,afterShow);
			_model					.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_UPADTA_CONPLETE_REC),resfhRec);
			
//			//精英副本底图
//			_myDis.backMc.source	=	ResPath.PNG	+	"EliteBack.png";
			_myDis.windowBG.helpBtnVisible = true ; 
		}
		/**
		 * 显示单元项
		 * @param mc
		 * @param data
		 * 
		 */		
		private function showItem(mc:MovieClip,data:Object):void
		{
			var pic:NxClip	=	mc["Image"] as NxClip;
			if(data != null)
			{
				mc.visible	=	true;
				if(_FBTaskLogic.isCompleteFB(data["preFBID"],data["TaskCompleteID"]))
				{
					pic.source				=	ResPath.JPG +data["chapterMiniPic"] + ".jpg";
					mc["Title"].htmlText	=	StaticIni.getSwfLangStr(data["chapterName"]);
					if(_FBTaskLogic.isCanIntoFB(data["chapterEnterScene"]))
					{
						mc["isShow"]	=	true;
						pic.filters		=	[];
						mc.addEventListener(MouseEvent.MOUSE_OVER,	itemOverHandle);
						mc.addEventListener(MouseEvent.MOUSE_OUT,	itemOutHandle);
						mc.addEventListener(MouseEvent.CLICK,		itemClickHandle);
					}
					else
					{
						mc["isShow"]	=	false;
						pic.filters		=	[FilterUtil.GrayColorFilter];
						_isanew = true;
						mc.gotoAndStop(1);
						mc.addEventListener(MouseEvent.MOUSE_OVER,	itemOverHandle);
						mc.addEventListener(MouseEvent.MOUSE_OUT,	itemOutHandle);
					}
				}
				else
				{
					pic.filters		=	[];
					pic.source		=	ResPath.JPG + "FBListSceneS_0000.jpg";
				}
				mc["data"]			=	data;
			}
		}
		/**
		 * 删除单元项
		 * @param mc
		 * 
		 */		
		private function removeItem(mc:MovieClip):void
		{
			
			(mc["Btn"]		as NxButton)	.visible	=	false;
			(mc["sdBtn"]		as NxButton)	.visible	=	false;
			(mc["Image"]	as NxClip)		.source		=	null;
			(mc["Title"]	as TextField)	.text		=	"";
			mc["data"]									=	null;
			mc								.visible	=	false;
			mc								.filters	=	[];
			mc.removeEventListener(MouseEvent.MOUSE_OVER,	itemOverHandle);
			mc.removeEventListener(MouseEvent.MOUSE_OUT,	itemOutHandle);
			mc.removeEventListener(MouseEvent.CLICK,		itemClickHandle);
			(mc["Btn"] as NxButton).removeEventListener(MouseEvent.CLICK,btnClickHandle);
			(mc["sdBtn"] as NxButton).removeEventListener(MouseEvent.CLICK,sdbtnClickHandle);
		}
		/**
		 * 翻页后的操作函数
		 */		
		private function afterShow():void
		{
			isCanRes();
			_isanew = false;
			//显示标题
			var pageIndex:int		=	_turnPagersViewGroup.nowPage;
			var listObj	:Object		=	StaticIni.getIniObj("JY_"+ String(1 + pageIndex));
			_myDis.titleimage.source = ResPath.PNG	+	listObj["actName"] +".png";
			//显示点击项
			var selectIndex:int		=	_turnPagersViewGroup.chooseIndex;
			if(selectIndex != -1)
			{
				var itemMC:MovieClip	=	_myDis.fb_frame.getItemByIndex(selectIndex);
				itemMC.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
			}
			else
			{
				if(_oldItem != null)
				{
					_oldItem.gotoAndStop(1);
					_oldItem["Btn"].visible		=	false;
					_oldItem["sdBtn"].visible		=	false;
				}
				_myDis.intoEffect.stop();
				_myDis.intoEffect.visible	=	false;
			}
			checkIsCanWipe(1 +pageIndex);
		}
		/**
		 * 遍历精英副本列表项
		 */		
		public function showInfo():void
		{
			_turnPagersViewGroup.clear();
			_fbListArray		=	[];
			
			var checkObj		:Object;
			var	itemObj			:Object;
			var count			:int
			for(var i:int = _starInt; i<= _endInt; i++)
			{
				checkObj	=	StaticIni.getIniObj("JY_" + String(i)) as Object;
				count		=	checkObj["countChapter"];
				for(var j:int = 1; j <= count;  j++)
				{
					itemObj	=	StaticIni.getIniObj("JY_" + String(i) + "_"+  String(j) ) as Object;
					if(j > 1)
					{
						itemObj["preFBID"]	=	StaticIni.getIniObj("JY_" + String(i) + "_"+  String(j - 1) )["chapterEnterScene"];
					}
					else
					{
						itemObj["preFBID"]	= 0;
					}
					_fbListArray.push(itemObj);
				}
				
				for(var m:int = count; m < _myDis.fb_frame.col * _myDis.fb_frame.row; m++)
				{
					_fbListArray.push(null);
				}
				//是否需要继续遍历下去
				if(!_FBTaskLogic.isCompleteFB(itemObj["chapterEnterScene"],itemObj["TaskCompleteID"]))break;
			}
			_turnPagersViewGroup.dataProvider	=	_fbListArray;
			checkIntoTaskFbID();
		}
		//刷新副本并保存当前页
		public function showInfoPage():void
		{
			_turnPagersViewGroup.Pageclear();
			_fbListArray		=	[];
			
			var checkObj		:Object;
			var	itemObj			:Object;
			var count			:int
			for(var i:int = _starInt; i<= _endInt; i++)
			{
				checkObj	=	StaticIni.getIniObj("JY_" + String(i)) as Object;
				count		=	checkObj["countChapter"];
				for(var j:int = 1; j <= count;  j++)
				{
					itemObj	=	StaticIni.getIniObj("JY_" + String(i) + "_"+  String(j) ) as Object;
					if(j > 1)
					{
						itemObj["preFBID"]	=	StaticIni.getIniObj("JY_" + String(i) + "_"+  String(j - 1) )["chapterEnterScene"];
					}
					else
					{
						itemObj["preFBID"]	= 0;
					}
					_fbListArray.push(itemObj);
				}
				
				for(var m:int = count; m < _myDis.fb_frame.col * _myDis.fb_frame.row; m++)
				{
					_fbListArray.push(null);
				}
				//是否需要继续遍历下去
				if(!_FBTaskLogic.isCompleteFB(itemObj["chapterEnterScene"],itemObj["TaskCompleteID"]))break;
			}
			_turnPagersViewGroup.dataProviderPage	=	_fbListArray;
//			checkIntoTaskFbID();
		}
		/**
		 * 初始化图片组，向里面加入一个NxClip和一个按钮;
		 */		
		private function initItemPic():void
		{
			for(var i:int = 0; i < _myDis.fb_frame.col * _myDis.fb_frame.row; i++)
			{
				var itemMc:MovieClip	=	_myDis.fb_frame.getItemByIndex(i) as MovieClip;
				//去除小星星
				for (var j:int = 0; j < 5; j++) 
				{
					var star:MovieClip	=	itemMc.getChildByName("s" + j) as MovieClip;
					star.gotoAndStop(1);
					star.visible		=	false	
				}
				var pic:NxClip			=	new NxClip();
				var btn:NxButton		=	new NxButton();
				var sdBtn:NxButton		= 	new NxButton();
				var titleTxt:TextField	=	itemMc.getChildByName("title") as TextField;
				var picSpace:MovieClip	=	itemMc.getChildByName("pic") as MovieClip;
				pic.isCache				=	true;
				picSpace.addChild(pic);
				btn.width	=	50;
				btn.height	=	30;
				btn.skin	=	"Button_2";
				btn.label	=	"进入";
				btn.x		=	20;
				btn.y		=	93;
				itemMc.addChild(btn);
				
				sdBtn.width	=	50;
				sdBtn.height	=	30;
				sdBtn.skin	=	"Button_2";
				sdBtn.label	=	"扫荡";
				sdBtn.x		=	80;
				sdBtn.y		=	93;
				itemMc.addChild(btn);
				itemMc.addChild(sdBtn);
				
				itemMc["Btn"]		=	btn;
				itemMc["sdBtn"]	=	sdBtn;
				itemMc["Image"]	=	pic;
				itemMc["Title"]	=	titleTxt;
				itemMc["index"]	=	i;
				itemMc.offsetCol 	= 	4 ; 
				itemMc.gotoAndStop(1);
				/**不记住状态**/	
				itemMc["fit"]		=	1;
			}
		}
		/**
		 * 检查是否需要打开指定的副本子项;
		 * 如没有指定，打开最后一个可进入的
		 */
		private function checkIntoTaskFbID():void
		{
			var canIndex:int	=	0;
			var needIndex:int	=	-1;
			var item:Object	=	{};
			for(var i:int = 0; i < _fbListArray.length; i++)
			{
				item	=	_fbListArray[i] as Object
				if(item != null)
				{
					if(_FBTaskLogic.isCompleteFB(item["preFBID"],item["TaskCompleteID"]))
					{
						canIndex = i;
					}
					if(_FBSceneID != "")
					{
						if(item["chapterEnterScene"] == _FBSceneID)
						{
							needIndex = i;
						}
					}
				}
			}
			if(_FBSceneID != "")
			{
				if(needIndex == -1)
				{
					_isCanInitFbIndex	=	canIndex;
				}
				else
				{
					_isCanInitFbIndex	=	needIndex > canIndex	?	canIndex : needIndex;
				}
			}
			else
			{
				_isCanInitFbIndex	=	canIndex;
			}
			_turnPagersViewGroup.chooseDataItem	=	_isCanInitFbIndex;
		}
		/**
		 * 显示当前的副本项目是否要有标识 
		 * @param val
		 * 
		 */		
		private function checkShowEffect(val:MovieClip):void
		{
			_myDis.intoEffect.stop();
			_myDis.intoEffect.visible	=	false;
			
			if(_FBSceneID != "")
			{
				if(_isCanInitFbIndex == (_turnPagersViewGroup.nowPage - 1) * _myDis.fb_frame.col * _myDis.fb_frame.row + val["index"])
				{
					if(_FBSceneType == FBTaskLogic.PK_FB)
					{
						_myDis.intoEffect.play();
						_myDis.intoEffect.visible	=	true;
						_myDis.intoEffect.x			=	_myDis.fb_frame.x + val.x + val.width -30;
						_myDis.intoEffect.y			=	_myDis.fb_frame.y + val.y 
					}
				}
			}
		}
		/**
		 * 检查当前章节是否有可扫荡的副本 
		 * @param val
		 * 
		 */		
		private function checkIsCanWipe(val:int):void
		{
			var checkItem:Object	=	{};
			var checkObj:Object		=	StaticIni.getIniObj("JY_" + String(val)) as Object;	
			for(var i:int = 1; i <= checkObj["countChapter"]; i++)
			{
				checkItem	=	StaticIni.getIniObj("JY_" + String(val) + "_"+  String(i) ) as Object;
				if(i ==1)
				{
					_fristFBSceneObj	=	checkItem
				}
				if(_FBTaskLogic.isCompleteFB(checkItem["chapterEnterScene"],checkItem["TaskCompleteID"]))
				{
					if(_FBTaskLogic.isCanIntoFB(checkItem["chapterEnterScene"]))
					{
						_myDis.wipeout.visible	=	true;
						return;
					}
				}

			}
			_myDis.wipeout.visible	=	false;
		}
		/**
		 * 移出效果 
		 * @param e
		 * 
		 */		
		private function itemOutHandle(e:MouseEvent):void
		{
			var target:MovieClip	=	e.currentTarget as MovieClip;
//			if(target.currentFrame == 3)return;
			TipsMainLogic.instance.hide();
			if(target["isShow"]&&target.currentFrame == 3)
			{
				
			}else if(target["isShow"])
			{
				target.gotoAndStop(1);
			}
		}
		/**
		 * 移入 
		 * @param e
		 * 
		 */		
		private function itemOverHandle(e:MouseEvent):void
		{
			var target:MovieClip	=	e.currentTarget as MovieClip;
//			if(target.currentFrame == 3)return;
			var tip:String=StaticIni.getSwfLangStr(target["data"]["chapterDropDes"]) ;
			TipsMainLogic.instance.showString(tip);
			if(target["isShow"]&&target.currentFrame == 3)
			{
				
			}else if(target["isShow"])
			{
				target.gotoAndStop(2);
			}

		}
		/**
		 * 点击副本项 
		 * @param e
		 * 
		 */		
		private function itemClickHandle(e:MouseEvent):void
		{
			var target:MovieClip	=	e.currentTarget as MovieClip;
			if(target["data"] != null)
			{
				if(_oldItem != null)
				{
					_oldItem["Btn"].visible	=	false;
					_oldItem["sdBtn"].visible = false;
					_oldItem.gotoAndStop(1);
				}
				_oldItem				=	target;
				var val:int = _turnPagersViewGroup.nowPage +1;
				var checkItem:Object	=	{};
				var index:int = _myDis.fb_frame.getChildIndex(target)+1;
				checkItem	=	StaticIni.getIniObj("JY_" + String(val) + "_"+  String(index) ) as Object;
				if(_FBTaskLogic.curFBisCanAnew(checkItem["chapterEnterScene"]))
				{
					target["Btn"].visible	=	true;
					target["Btn"].x = 20;
					target["sdBtn"].visible	=	true;
					target["sdBtn"].x = 80;
				}else
				{
					target["Btn"].visible	=	true;
					target["Btn"].x = 55;
					target["sdBtn"].visible	=	false;
				}
				
				
				target.gotoAndStop(3);
				_turnPagersViewGroup.chooseIndex	=	target["pageIndex"];
				(target["Btn"] as NxButton).addEventListener(MouseEvent.CLICK,btnClickHandle);
				(target["sdBtn"] as NxButton).addEventListener(MouseEvent.CLICK,sdbtnClickHandle);
				TipsMainLogic.instance.hide();
			}

		}
		
		private function sdbtnClickHandle(e:MouseEvent):void
		{
			var val:int = _turnPagersViewGroup.nowPage +1;
			
			var checkObj:Object		=	StaticIni.getIniObj("JY_" + val ) as Object;	
			var checkItem:Object	=	{};
			var index:int = _myDis.fb_frame.getChildIndex(e.currentTarget.parent)+1;
			checkItem	=	StaticIni.getIniObj("JY_" + String(val) + "_"+  String(index) ) as Object;
			
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_SWEEP_ELITE_FB, 
				int(checkItem["chapterEnterScene"]),1);
		}
		
		/**
		 * 进入副本PK去了 
		 * @param e
		 * 
		 */		
		private function btnClickHandle(e:MouseEvent):void
		{
			var target:MovieClip	=	(e.currentTarget	as NxButton).parent as MovieClip;
			
			if(target["data"] != null)
			{
				if(TaskTrackingUI.getInstance().TaskIdList(target["data"]["TaskID"])&&target["fit"]==1)
				{
					var str:String = StaticIni.getSwfLangStr("Task_AcceptNpc"+target["data"]["TaskID"]) ;
					var startIndex : int =  str.indexOf( "event:" ) + 6;
					var endIndex : int = str.indexOf( "'", startIndex );
					
					var _acceptTask:String = str.substr( startIndex, endIndex - startIndex );
					
					SitAlerLogic.getIntatic().setGiveUp_FB(StaticIni.getSwfLangStr( "UIString_1000680" ),[],noClick,okClick,target,true,true);
					function okClick():void
					{
						SceneTransfer.getInstance().tranferTo(_acceptTask);
					}
					function noClick():void
					{
						SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_ELITE_FB_ENTER, int(target["data"]["chapterEnterScene"]));
					}
					
				}else
				{
					SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_ELITE_FB_ENTER, int(target["data"]["chapterEnterScene"]));
				}
				
			}
		}
		/**
		 * 
		 * @param e
		 * 
		 */
		private function OverhelpHandler(e:MouseEvent):void
		{
			var tip:String = StaticIni.getSwfLangStr("UIString_1000454"); 
			TipsMainLogic.instance.showString(tip);
		}
		private function OuthelpHandler(e:MouseEvent):void
		{
			TipsMainLogic.instance.hide();
		}
		/**
		 * 功能按钮 
		 */		
		private function clickHandle(e:MouseEvent):void
		{
			var target:DisplayObject	=	e.currentTarget	as DisplayObject;
			switch(target)
			{
				case _myDis.anewBtn:
					if(FBTaskLogic.getInstance().isAnewBtn()==true)
					{
						NoticeUI.getInstance().showInfo(StaticIni.getSwfLangStr("UIString_1000460")); 
						
					}else
					{
						//重置副本
						SitAlerLogic.getIntatic().setUIinfo("UIStr_1001891",["200"],anewFB,_myDis.anewBtn);
						LogSendLogic.getInstance().btnClickNumSend(22824);
					}
					break;
				case _myDis.wipeout:
//					 if(DuplicatesLogic.getInstance().searchItem(int(VIPCONFIGID) ,1 )>0&&_model.scene.Role.getVipLevel()==0)
//					 {
//						 AlertUI.showAlert("",StaticIni.getSwfLangStr("VIPTips_14"),AlertUI.OK|AlertUI.CANCEL,YesFun);
//						 
//					 }else
//					 {
						 SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_SWEEP_ELITE_FB, int(_fristFBSceneObj["chapterEnterScene"]));
//					 }
					
					break;
			}
		}
		/**
		 */
		private function YesFun(type:int, str:String, clickData:*):void
		{
			if(AlertUI.OK == type )
			{
				
				if(DuplicatesLogic.getInstance()._itemObj.hasOwnProperty("VIEWPORT_TOOL"))
				{
					SystemSender.getInstance().CustomMsg( CustomToServerFlag.CLIENT_CUSTOMMSG_USEITEM,DuplicatesLogic.getInstance()._itemObj["VIEWPORT_TOOL"], DuplicatesLogic.getInstance()._itemObj["PackIndex"]  );
				}else if(DuplicatesLogic.getInstance()._itemObj.hasOwnProperty("VIEWPORT_STORE"))
				{
					SystemSender.getInstance().CustomMsg( CustomToServerFlag.CLIENT_CUSTOMMSG_USEITEM,DuplicatesLogic.getInstance()._itemObj["VIEWPORT_STORE"], DuplicatesLogic.getInstance()._itemObj["DuIndex"] );
				}
				
			}else if(AlertUI.NO == type)
			{
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_SWEEP_ELITE_FB, int(_fristFBSceneObj["chapterEnterScene"]));
			}
		}
		/**
		 *重置 
		 */		
		private function anewFB():void
		{
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_REST_ELITE_FB_COUNT,
				int(_fristFBSceneObj["chapterEnterScene"]));
		}
		/**
		 * 刷新副本 
		 * @param e
		 * 
		 */		
		private function resfhRec(e:CustomMsgEvent):void
		{
			showInfoPage();
		}
		/**
		 * 是否显示重置按钮
		 */		
		private function isCanRes():void
		{
			if(_levle >= 3)
			{
				if(_resNum == 0)
				{
					if(_isanew)
					{//是不是有可以重置的项
						_myDis.anewBtn.visible	=	true;
					}else
					{
						_myDis.anewBtn.visible	=	false;
					}
					
				}
				else
				{
					//绑定表格
					if(_blindFlag==-1)
					{
						_myDis.anewBtn.visible	=	false;
						_blindFlag = BindManage.getInstance().BindRecord(_model.scene,"VIPCountRec",onaddPerHandle,onremovePerHandle);
					}
					if(_eliteFBCount > 0){
						_myDis.anewBtn.visible =true;
					} else {
						_myDis.anewBtn.visible =false;
					}
				}
			}
			else
			{
				if(_isanew)
				{//是不是有可以重置的项
					//绑定表格
					if(_blindFlag==-1)
					{
						_myDis.anewBtn.visible	=	false;
						_blindFlag = BindManage.getInstance().BindRecord(_model.scene,"VIPCountRec",onaddPerHandle,onremovePerHandle);
					}
					if(_eliteFBCount > 0){
						_myDis.anewBtn.visible =true;
					} else {
						_myDis.anewBtn.visible =false;
					}
				}else
				{
					_myDis.anewBtn.visible	=	false;
				}
			}
		}
		/**
		 * 关闭窗口 
		 * @param e
		 * 
		 */		
		private function closeHandle(e:NxWindowEvent):void
		{
			_WindowIsOk				=	false;
			_myDis.showOrHide();
		}
		
		private function onaddPerHandle(PropertiesName:String,PropertiesValue:Array,data:*):void
		{
			if(PropertiesValue[0] == ELITEFBLIST_TYPE){
				var useCount:int = PropertiesValue[1];
				var allCount:int = PropertiesValue[2];
				var cardCount:int = PropertiesValue[3];
				_eliteFBCount = allCount + cardCount - useCount;
				if(_eliteFBCount > 0){
					_myDis.anewBtn.visible = true;
				} else {
					_myDis.anewBtn.visible = false;
				}
			}
		}
		
		private function onremovePerHandle(PropertiesName:String,PropertiesValue:Array,data:*):void
		{
			
		}
	}
}